console.log("hello world！")

// 数值型 var:旧版本的变量类型；let:新版本的变量类型
let classNum = 42
let className = '枢云一部'
console.log(className + '有' + classNum + '人')
let un
console.log(un)
let b = true
console.log(b)

// ===:强等于  ==：忽略类型判断
console.log(classNum === 42)

// java: 10/3=3   js:10/3 = 3.333333........
console.log(10/3)

let i = 0
while (i < 10) {
    console.log("枢云一部" + i)
    i++
}

// 定义函数
function writeLine() {
    document.write("<h2>打印金字塔直线</h2>")
    for (let i= 0; i<100; i=i+5){
        document.write("<hr align='center' width='" + i + "%'>")
    }
}

// writeLine()

function Weapon(name, att) {
    this.name = name
    this.att = att
}

// 创建对象
let weapon = new Weapon("ak", 300)
// js获取对象属性的方式有两种
console.log(weapon.name)
console.log(weapon['att'])

console.log(weapon)

// 用Id获取对象
let inputObject = document.getElementById("user-name")
console.log(inputObject)
inputObject.placeholder = "请输入数据"

let divObject = document.getElementById("hezi-demo")
divObject.style.backgroundColor = "blue"

// 通过class获取对象
let elements = document.getElementsByClassName("css-class-demo")
console.log(elements)

// 定义一个可以改变颜色为粉色的函数
function changePink() {
    let divObj = document.getElementById("mouse-demo");
    divObj.style.backgroundColor = "pink"
}

// 定义一个可以改变颜色为红色的函数
function changeRed() {
    let divObj = document.getElementById("mouse-demo");
    divObj.style.backgroundColor = "red"
}



